home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / CIncludes / QD3DSet.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  10.3 KB  |  323 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        QD3DSet.h
  3.  
  4.      Contains:    Q3Set types and routines                                            
  5.  
  6.      Version:    Technology:    Quickdraw 3D 1.5.4
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1995-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __QD3DSET__
  18. #define __QD3DSET__
  19.  
  20. #ifndef __QD3D__
  21. #include <QD3D.h>
  22. #endif
  23.  
  24.  
  25.  
  26. #if PRAGMA_ONCE
  27. #pragma once
  28. #endif
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. #if PRAGMA_IMPORT
  35. #pragma import on
  36. #endif
  37.  
  38. #if PRAGMA_STRUCT_ALIGN
  39.     #pragma options align=power
  40. #elif PRAGMA_STRUCT_PACKPUSH
  41.     #pragma pack(push, 2)
  42. #elif PRAGMA_STRUCT_PACK
  43.     #pragma pack(2)
  44. #endif
  45.  
  46. #if PRAGMA_ENUM_ALWAYSINT
  47.     #pragma enumsalwaysint on
  48. #elif PRAGMA_ENUM_OPTIONS
  49.     #pragma option enum=int
  50. #elif PRAGMA_ENUM_PACK
  51.     #if __option(pack_enums)
  52.         #define PRAGMA_ENUM_PACK__QD3DSET__
  53.     #endif
  54.     #pragma options(!pack_enums)
  55. #endif
  56.  
  57. /******************************************************************************
  58.  **                                                                             **
  59.  **                                Set Routines                                 **
  60.  **                                                                             **
  61.  *****************************************************************************/
  62. EXTERN_API_C( TQ3SetObject )
  63. Q3Set_New                        (void);
  64.  
  65. EXTERN_API_C( TQ3ObjectType )
  66. Q3Set_GetType                    (TQ3SetObject             theSet);
  67.  
  68. EXTERN_API_C( TQ3Status )
  69. Q3Set_Add                        (TQ3SetObject             theSet,
  70.                                  TQ3ElementType         theType,
  71.                                  const void *            data);
  72.  
  73. EXTERN_API_C( TQ3Status )
  74. Q3Set_Get                        (TQ3SetObject             theSet,
  75.                                  TQ3ElementType         theType,
  76.                                  void *                    data);
  77.  
  78. EXTERN_API_C( TQ3Boolean )
  79. Q3Set_Contains                    (TQ3SetObject             theSet,
  80.                                  TQ3ElementType         theType);
  81.  
  82. EXTERN_API_C( TQ3Status )
  83. Q3Set_Clear                        (TQ3SetObject             theSet,
  84.                                  TQ3ElementType         theType);
  85.  
  86. EXTERN_API_C( TQ3Status )
  87. Q3Set_Empty                        (TQ3SetObject             target);
  88.  
  89. /*
  90.  *  Iterating through all elements in a set
  91.  *
  92.  *  Pass in kQ3ElementTypeNone to get first type
  93.  *  kQ3ElementTypeNone is returned when end of list is reached
  94.  */
  95. EXTERN_API_C( TQ3Status )
  96. Q3Set_GetNextElementType        (TQ3SetObject             theSet,
  97.                                  TQ3ElementType *        theType);
  98.  
  99.  
  100. /******************************************************************************
  101.  **                                                                             **
  102.  **                                Attribute Types                                 **
  103.  **                                                                             **
  104.  *****************************************************************************/
  105. /* 
  106.  *    For the data types listed below, pass in a pointer to it in the _Add 
  107.  *    and _Get calls.
  108.  *
  109.  *    For surface shader attributes, reference counts are incremented on 
  110.  *    the _Add and _Get 
  111.  */
  112.  
  113. enum TQ3AttributeTypes {
  114.                                                                 /* Data Type                */
  115.     kQ3AttributeTypeNone        = 0,                            /* ---------                */
  116.     kQ3AttributeTypeSurfaceUV    = 1,                            /* TQ3Param2D                */
  117.     kQ3AttributeTypeShadingUV    = 2,                            /* TQ3Param2D                 */
  118.     kQ3AttributeTypeNormal        = 3,                            /* TQ3Vector3D                 */
  119.     kQ3AttributeTypeAmbientCoefficient = 4,                        /* float                     */
  120.     kQ3AttributeTypeDiffuseColor = 5,                            /* TQ3ColorRGB                */
  121.     kQ3AttributeTypeSpecularColor = 6,                            /* TQ3ColorRGB                */
  122.     kQ3AttributeTypeSpecularControl = 7,                        /* float                    */
  123.     kQ3AttributeTypeTransparencyColor = 8,                        /* TQ3ColorRGB                */
  124.     kQ3AttributeTypeSurfaceTangent = 9,                            /* TQ3Tangent2D              */
  125.     kQ3AttributeTypeHighlightState = 10,                        /* TQ3Switch                 */
  126.     kQ3AttributeTypeSurfaceShader = 11,                            /* TQ3SurfaceShaderObject    */
  127.     kQ3AttributeTypeNumTypes    = 12
  128. };
  129. typedef enum TQ3AttributeTypes TQ3AttributeTypes;
  130.  
  131. typedef TQ3ElementType                     TQ3AttributeType;
  132. /******************************************************************************
  133.  **                                                                             **
  134.  **                                Attribute Drawing                             **
  135.  **                                                                             **
  136.  *****************************************************************************/
  137. EXTERN_API_C( TQ3Status )
  138. Q3Attribute_Submit                (TQ3AttributeType         attributeType,
  139.                                  const void *            data,
  140.                                  TQ3ViewObject             view);
  141.  
  142.  
  143. /******************************************************************************
  144.  **                                                                             **
  145.  **                            AttributeSet Routines                             **
  146.  **                                                                             **
  147.  *****************************************************************************/
  148. EXTERN_API_C( TQ3AttributeSet )
  149. Q3AttributeSet_New                (void);
  150.  
  151. EXTERN_API_C( TQ3Status )
  152. Q3AttributeSet_Add                (TQ3AttributeSet         attributeSet,
  153.                                  TQ3AttributeType         theType,
  154.                                  const void *            data);
  155.  
  156. EXTERN_API_C( TQ3Boolean )
  157. Q3AttributeSet_Contains            (TQ3AttributeSet         attributeSet,
  158.                                  TQ3AttributeType         attributeType);
  159.  
  160. EXTERN_API_C( TQ3Status )
  161. Q3AttributeSet_Get                (TQ3AttributeSet         attributeSet,
  162.                                  TQ3AttributeType         theType,
  163.                                  void *                    data);
  164.  
  165. EXTERN_API_C( TQ3Status )
  166. Q3AttributeSet_Clear            (TQ3AttributeSet         attributeSet,
  167.                                  TQ3AttributeType         theType);
  168.  
  169. EXTERN_API_C( TQ3Status )
  170. Q3AttributeSet_Empty            (TQ3AttributeSet         target);
  171.  
  172. /*
  173.  * Q3AttributeSet_GetNextAttributeType
  174.  *
  175.  * Pass in kQ3AttributeTypeNone to get first type
  176.  * kQ3AttributeTypeNone is returned when end of list is reached
  177.  */
  178. EXTERN_API_C( TQ3Status )
  179. Q3AttributeSet_GetNextAttributeType (TQ3AttributeSet     source,
  180.                                  TQ3AttributeType *        theType);
  181.  
  182. EXTERN_API_C( TQ3Status )
  183. Q3AttributeSet_Submit            (TQ3AttributeSet         attributeSet,
  184.                                  TQ3ViewObject             view);
  185.  
  186. /*
  187.  * Inherit from parent->child into result
  188.  *    Result attributes are:
  189.  *        all child attributes + all parent attributes NOT in the child
  190.  */
  191. EXTERN_API_C( TQ3Status )
  192. Q3AttributeSet_Inherit            (TQ3AttributeSet         parent,
  193.                                  TQ3AttributeSet         child,
  194.                                  TQ3AttributeSet         result);
  195.  
  196.  
  197. /******************************************************************************
  198.  **                                                                             **
  199.  **                            Custom Element Registration                         **
  200.  **                                                                             **
  201.  *****************************************************************************/
  202. /*
  203.  * Element Methods - 
  204.  *
  205.  *         When you create a custom element, you control what structures are 
  206.  *        passed around the API. For example, you may allow the Q3Set_Add call 
  207.  *        take one type of argument, store your element internally in some 
  208.  *        abstract data type, and have the Q3Set_Get call take a different 
  209.  *        argument.
  210.  *
  211.  *        For example:
  212.  *            
  213.  *        There are four calls which at some point will copy an element:
  214.  *
  215.  *        Q3Set_Add (copied from Application memory to QuickDraw3D memory)
  216.  *        Q3Set_Get (copied from QuickDraw3D memory to Application memory)
  217.  *        Q3Object_Duplicate (all elements are copied internally)
  218.  *        Q3AttributeSet_Inherit (all elements are copied internally)
  219.  *
  220.  *         Either CopyAdd or CopyReplace is called during the "_Add" call.
  221.  *            - CopyAdd is destructive and should assume "toElement" is garbage
  222.  *            - CopyReplace is replacing an existing element.
  223.  *
  224.  *         CopyGet is called during the "_Get" call.
  225.  *
  226.  *         CopyDuplicate is called to duplicate an element's internal structure.
  227.  *
  228.  * Attributes Methods - 
  229.  *
  230.  *        For copying data while Inheriting. Element methods are used
  231.  *        at all other times.
  232.  *    
  233.  *         CopyInherit is called to duplicate an element's internal structure 
  234.  *            during inheritance. You should make this as fast as possible.
  235.  *            (for example, if your custom element contains objects, you
  236.  *             should do a Q3Shared_GetReference instead of a Q3Object_Duplicate)
  237.  *            
  238.  *        The ElementDelete method will be called for all of your elements 
  239.  *        copied around via CopyAdd, CopyReplace, CopyDuplicate, and 
  240.  *        CopyInherit.
  241.  *        If CopyGet allocates any memory in it's destination, it is up to the 
  242.  *        application to delete it on its side.
  243.  */
  244. #define kQ3XMethodTypeElementCopyAdd            Q3_METHOD_TYPE('e','c','p','a')
  245. #define kQ3XMethodTypeElementCopyReplace        Q3_METHOD_TYPE('e','c','p','r')
  246. #define kQ3XMethodTypeElementCopyGet            Q3_METHOD_TYPE('e','c','p','g')
  247. #define kQ3XMethodTypeElementCopyDuplicate        Q3_METHOD_TYPE('e','c','p','d')
  248. #define kQ3XMethodTypeElementDelete                Q3_METHOD_TYPE('e','d','e','l')
  249. typedef CALLBACK_API_C( TQ3Status , TQ3XElementCopyAddMethod )(const void *fromAPIElement, void *toInternalElement);
  250. typedef CALLBACK_API_C( TQ3Status , TQ3XElementCopyReplaceMethod )(const void *fromAPIElement, void *ontoInternalElement);
  251. typedef CALLBACK_API_C( TQ3Status , TQ3XElementCopyGetMethod )(const void *fromInternalElement, void *toAPIElement);
  252. typedef CALLBACK_API_C( TQ3Status , TQ3XElementCopyDuplicateMethod )(const void *fromInternalElement, void *toInternalElement);
  253. typedef CALLBACK_API_C( TQ3Status , TQ3XElementDeleteMethod )(void *internalElement);
  254. EXTERN_API_C( TQ3XObjectClass )
  255. Q3XElementClass_Register        (TQ3ElementType *        elementType,
  256.                                  const char *            name,
  257.                                  unsigned long             sizeOfElement,
  258.                                  TQ3XMetaHandler         metaHandler);
  259.  
  260. EXTERN_API_C( TQ3Status )
  261. Q3XElementType_GetElementSize    (TQ3ElementType         elementType,
  262.                                  unsigned long *        sizeOfElement);
  263.  
  264.  
  265. /******************************************************************************
  266.  **                                                                             **
  267.  **                        Custom Attribute Registration                         **
  268.  **                                                                             **
  269.  *****************************************************************************/
  270. #define kQ3XMethodTypeAttributeInherit        Q3_METHOD_TYPE('i','n','h','t')
  271. typedef TQ3Boolean                         TQ3XAttributeInheritMethod;
  272. /* return kQ3True or kQ3False in your metahandler */
  273. #define kQ3XMethodTypeAttributeCopyInherit    Q3_METHOD_TYPE('a','c','p','i')
  274. typedef CALLBACK_API_C( TQ3Status , TQ3XAttributeCopyInheritMethod )(const void *fromInternalAttribute, void *toInternalAttribute);
  275. EXTERN_API_C( TQ3XObjectClass )
  276. Q3XAttributeClass_Register        (TQ3AttributeType *        attributeType,
  277.                                  const char *            creatorName,
  278.                                  unsigned long             sizeOfElement,
  279.                                  TQ3XMetaHandler         metaHandler);
  280.  
  281. /*
  282.  *    Version 1.5
  283.  */
  284. #define kQ3XMethodTypeAttributeDefault        Q3_METHOD_TYPE('a','s','d','f')
  285. typedef CALLBACK_API_C( TQ3Status , TQ3XAttributeDefaultMethod )(void *internalElement);
  286. #define kQ3XMethodTypeAttributeIsDefault        Q3_METHOD_TYPE('a','i','d','f')
  287. typedef CALLBACK_API_C( TQ3Boolean , TQ3XAttributeIsDefaultMethod )(void *internalElement);
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295. #if PRAGMA_ENUM_ALWAYSINT
  296.     #pragma enumsalwaysint reset
  297. #elif PRAGMA_ENUM_OPTIONS
  298.     #pragma option enum=reset
  299. #elif defined(PRAGMA_ENUM_PACK__QD3DSET__)
  300.     #pragma options(pack_enums)
  301. #endif
  302.  
  303. #if PRAGMA_STRUCT_ALIGN
  304.     #pragma options align=reset
  305. #elif PRAGMA_STRUCT_PACKPUSH
  306.     #pragma pack(pop)
  307. #elif PRAGMA_STRUCT_PACK
  308.     #pragma pack()
  309. #endif
  310.  
  311. #ifdef PRAGMA_IMPORT_OFF
  312. #pragma import off
  313. #elif PRAGMA_IMPORT
  314. #pragma import reset
  315. #endif
  316.  
  317. #ifdef __cplusplus
  318. }
  319. #endif
  320.  
  321. #endif /* __QD3DSET__ */
  322.  
  323.